﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QuanLyTiemVang.DAO
{
    class ChiTietPhieuNhapKhoDAO
    {
        private static QUANLYTIEMVANGEntities dbContext = new QUANLYTIEMVANGEntities();

        static public List<CHITIETPHIEUNHAPKHO> GetAllChiTietPhieuMuaHang()
        {
            var query = from d in dbContext.CHITIETPHIEUNHAPKHOes
                        select d;

            if (query.ToList().Count == 0)
                return null;

            return query.ToList();
        }
        public static void Insert(CHITIETPHIEUNHAPKHO ctpnk)
        {
            dbContext.CHITIETPHIEUNHAPKHOes.Add(ctpnk);
            dbContext.SaveChanges();
        }
        public static void Delete(CHITIETPHIEUNHAPKHO ctpnk)
        {
            if (dbContext.CHITIETPHIEUNHAPKHOes.Find(ctpnk) == null)
                return;

            dbContext.CHITIETPHIEUNHAPKHOes.Remove(ctpnk);
            dbContext.SaveChanges();
        }
    }
}
